﻿using Mes.Domain.BoundedContext.Entities.Operations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Mes.Infrastructure.Data.BoundedContext.EntityTypeConfigurations.Operations
{
    public class ItemProcessLinkEntityConfig : IEntityTypeConfiguration<ItemProcessLink>
    {
        public void Configure(EntityTypeBuilder<ItemProcessLink> builder)
        {
            builder.ToTable("item_process_link");
            builder.Property(b => b.MaterialId).IsRequired();
            builder.Property(b => b.Process_Id).HasMaxLength(40).IsRequired();
            builder.HasKey(b => new { b.Process_Id, b.MaterialId });
            builder.Property(b => b.Item_Pref).IsRequired();
            builder.Property(b => b.Status).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Last_Edit_Comment).HasMaxLength(254).IsRequired();
            builder.Property(b => b.Last_Edit_By).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Last_Edit_At).IsRequired();
            builder.Property(b => b.Mod_Id).IsRequired();
            builder.Property(b => b.Row_Id).IsRequired().UseIdentityColumn().HasIdentityOptions(startValue: 0, incrementBy: 1, minValue: 0);
        }
    }
}
